package com.craney.testTextField
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class LoadCssFile
	{
		private var tf:TextField = new TextField();
		
		private var txt:String = "<h1>This is a headline</h1>" + 
				"<p>This is a line text: <span class='bluetext'>" + 
				"This line of text is colored blue.</span></p>";
		
		private var loader:URLLoader = new URLLoader();
		
		private var parentSprite:Sprite;
		
		public function LoadCssFile(ps:Sprite)
		{
			tf.width = 300;
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.wordWrap = true;
			tf.border = true;
			tf.background = true;
			parentSprite = ps;
			parentSprite.addChild(tf);
			
			var url:URLRequest = new URLRequest("myCss.css");
			loader.addEventListener(Event.COMPLETE, complete);
			loader.load(url);
			
		}
		
		private function complete(event:Event):void
		{
			var myStyle:StyleSheet = new StyleSheet();
			myStyle.parseCSS(loader.data);
			tf.styleSheet= myStyle;
			tf.htmlText = txt;
		}

	}
}